package cn.initcap.session;

import cn.initcap.properties.SecurityProperties;
import java.io.IOException;
import javax.servlet.ServletException;
import org.springframework.security.web.session.SessionInformationExpiredEvent;
import org.springframework.security.web.session.SessionInformationExpiredStrategy;


/**
 * 并发登录导致session失效时，默认的处理策略
 *
 * @author initcap
 * @date 2018/5/24 PM2:02
 */
public class InitcapExpiredSessionStrategy extends AbstractSessionStrategy implements SessionInformationExpiredStrategy {

    public InitcapExpiredSessionStrategy(SecurityProperties securityPropertie) {
        super(securityPropertie);
    }

    @Override
    public void onExpiredSessionDetected(SessionInformationExpiredEvent event) throws IOException, ServletException {
        onSessionInvalid(event.getRequest(), event.getResponse());
    }

    @Override
    protected boolean isConcurrency() {
        return true;
    }

}
